package com.apes.bi.service;

import com.apes.bi.repository.CanvasContentRepository;
import com.apes.bi.repository.CanvasRepository;
import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("canvasContentService")

public class CanvasContentService extends DomainService {
    @Autowired
    CanvasContentRepository canvasContentRepository;
    @Autowired
    CanvasRepository canvasRepository;

//    public void update(SimpleRequest request){
//        JSONArray canvasContents = request.getJA();
//
//        // 删除原看板内容重新插入
//        Canvas canvas = canvasRepository.findOne(canvasContents.getJSONObject(0).getJSONObject("canvas").getString("id"));
//        canvas.deleteAllCanvasContent();
//
//        // 逐条保存
//        canvasContents.stream().forEach(item -> {
//            CanvasContent canvasContent = request.getO(CanvasContent.class);
//            canvasContentRepository.saveAndFlush(canvasContent);
//        });
//    }

}
